package com.efruit.shopcart;

public abstract class ShopCartFactory {
	private static Object initLock = new Object();
	private static String classNameProp = null;
	private static ShopCartFactory factory = null;

	public static ShopCartFactory getInstance() {
		if (factory == null) {
			synchronized (initLock) {
				if (factory == null) {
					classNameProp = Config
							.getProperty("ShopCartFactory.className");
					if(classNameProp == null){
						System.err.println("Failed to get property ShopCartFactory.className");
						System.exit(1);
					}
					try {
						Class c = Class.forName(classNameProp);
						factory = (ShopCartFactory) c.newInstance();
					} catch (Exception e) {
						System.err.println("Failed to load DAOFactoryclass "
								+ classNameProp + ".");
						e.printStackTrace();
						return null;
					}
				}
			}
		}
		return factory;
	}

	public abstract IProductInfoFetcher getProductInfoFetcher();
}
